package com.xjcs.notetools.ui

import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager
import com.xjcs.notetools.R
import com.xjcs.notetools.adapter.MainNavigationAdapter
import com.xjcs.notetools.adapter.VpFragmentAdapter
import com.xjcs.notetools.base.BaseMvvmActivity
import com.xjcs.notetools.bean.MainNavigationBean
import com.xjcs.notetools.bean.MainNavigationType
import com.xjcs.notetools.databinding.ActivityMainBinding

class MainActivity : BaseMvvmActivity<ActivityMainBinding>() {

    private val navigationList = mutableListOf<MainNavigationBean>()

    override fun init(savedInstanceState: Bundle?) {
        setContentView(R.layout.activity_main)
        initBottomNavigation()
    }

    private fun initBottomNavigation(){
        navigationList.clear()
        navigationList.add(MainNavigationBean(MainNavigationType.LIST, "事项", R.mipmap.ic_launcher, false))
        navigationList.add(MainNavigationBean(MainNavigationType.HABIT, "习惯", R.mipmap.ic_launcher, false))
        navigationList.add(MainNavigationBean(MainNavigationType.FOCUS, "专注", R.mipmap.ic_launcher, true))
        navigationList.add(MainNavigationBean(MainNavigationType.MEMO, "记事", R.mipmap.ic_launcher, false))
        navigationList.add(MainNavigationBean(MainNavigationType.MINE, "我的", R.mipmap.ic_launcher, false))

        binding.recyclerView.layoutManager = GridLayoutManager(this, 5)
        binding.recyclerView.adapter = MainNavigationAdapter(R.layout.item_main_tab, navigationList)

        binding.viewPager.adapter = VpFragmentAdapter(navigationList, this)
        binding.viewPager.offscreenPageLimit = 2
        binding.viewPager.isUserInputEnabled = false
    }

    override fun getViewBinding(): ActivityMainBinding {
        return ActivityMainBinding.inflate(layoutInflater)
    }
}